package com.wiscamp.ninechapters.problems.domain.models.challenges;

import cube.ddd.domain.Entity;
import lombok.Data;

/**
 * AMC竞赛历史数据统计信息
 */
@Data
public class AmcStatistic implements Entity {
    private long id;

    private long examId;

    private double percentOnePoints;

    private double percentFivePoints;

    private double percentQuarterPoints;

    private double percentHalfPoints;

    private double percentThreeQuarterPoints;

    private int highPoints;

    private int perfectStudents;

    private double averagePoints;

    private int totalStudents;

    private int totalSchools;

    private int examYear;

    private String abPaper = "";


    private int difficultLevel;

    public int getDifficultLevel() {
        int defaultLevel = 4;
        if (this.getExamYear() == 9999)
            return defaultLevel;

        if (this.getTotalStudents() > 0 && this.getPerfectStudents() > 0) {
            double value = this.getPerfectStudents() / this.getTotalStudents();
            if (value < 0.001) // 每一千人获得满分人数低于1
                return 5;
            if (value >= 0.001 && value < 0.002) // 每一千人获得满分人数大于1低于2
                return 4;
            if (value >= 0.002) // 每一千人获得满分人数大于等于2
                return 3;
        }
        return defaultLevel;
    }
}